﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PlanoAulaHelper
{
    public partial class ListPlanoAulaForm : FormEdicao
    {
        public ListPlanoAulaForm() : base(0)
        {
            InitializeComponent();
            CarregarGrid();
        }

        private void CarregarGrid()
        {
            using (dbContext dc = new dbContext())
            {
                planoAulaCabBindingSource.DataSource = from dados in dc.PlanoAulaCabs
                                                       select dados;
            }
        }
        //private void ExbirFormularioCadastro(int idSelecionado)
        //{
        //    var formulario = (from f in this.MdiParent.MdiChildren
        //                      where f.Name == "PlanoAulaCabForm"
        //                      select f).FirstOrDefault();
        //    if (formulario == null)
        //    {
        //        formulario = new PlanoAulaCabForm(idSelecionado);
        //        formulario.MdiParent = this.MdiParent;
        //        formulario.Show();
        //        CarregarGrid();
        //    }
        //    else
        //    {
        //        formulario.Activate();
        //    }
        //}
        private void toolStripButtonAdicionar_Click(object sender, EventArgs e)
        {
            new PlanoAulaCabForm(0).ExbirFormulario(this);
        }

        private void dgvItem_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int id = ((PlanoAulaCab)planoAulaCabBindingSource.Current).Id;
            new PlanoAulaCabForm(id).ExbirFormulario(this);
        }

        private void toolStripButtonPlanoDeAula_Click(object sender, EventArgs e)
        {
            int id = ((PlanoAulaCab)planoAulaCabBindingSource.Current).Id;
            new relPlanoAulaForm(id).ExbirFormulario(this);
        }

        private void detalhesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            dgvItem_MouseDoubleClick(sender, null);
        }

        
    }
}
